﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
using System.Text;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{

    public class AB55DIData : BaseFunction
    {
        
        public AB55DIData()
            : base()
        {

        }
        public AB55DIData(Dictionary<string, object> DicGlobalPara)
            : base(DicGlobalPara)
        {
        }
        public DataSet GetABFOLGE(DataSet dsTarget, DataRow dwABPOS)
        {
            string TableName = "ABFOLGE";
            try
            {
                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT DISTINCT B.LSNAME1 FROM ABFOLGE A,LIEFDAT B "
                    + " WHERE A.ABFMANDANT = B.LSMANDANT AND A.ABFLIEFNR = B.LSLIEFNR "
                    + " AND ABFMANUELKZ = 'N' AND ABFMANDANT = '00' AND ABFAUFKRS = :ABFAUFKRS  "
                    + " AND ABFAUFLFD = :ABFAUFLFD  AND ABFAUFPOS = :ABFAUFPOS  "
                     ;
                orlReadCommand.Parameters.Add("ABFAUFKRS", OracleType.NVarChar).Value = dwABPOS["ABPAUFKRS"].ToString().Trim();
                orlReadCommand.Parameters.Add("ABFAUFLFD", OracleType.NVarChar).Value = dwABPOS["ABPAUFLFD"].ToString().Trim();
                orlReadCommand.Parameters.Add("ABFAUFPOS", OracleType.NVarChar).Value = dwABPOS["ABPAUFPOS"].ToString().Trim();
                dsResult = Connect2Proxy(orlReadCommand);
                if (dsResult.Tables.Count > 0)
                {
                    dsResult.Tables[0].TableName = TableName;

                    byte[] b;
                    string value;
                    string ColumnName = "";
                    foreach (DataRow dw in dsResult.Tables["ABFOLGE"].Rows)
                    {
                        ColumnName = "LSNAME1";
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw[ColumnName].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dw[ColumnName] = value;

                        dwABPOS["LSNAME1"] = dw["LSNAME1"];
                    }
                }
                foreach (DataTable dtTemp in dsResult.Tables)
                {
                    if (dsTarget.Tables.Contains(TableName))
                    {
                        dsTarget.Tables[TableName].Clear();
                    }
                    dsTarget = ImportDataTable(dsTarget, dtTemp);
                }
                dsTarget.AcceptChanges();
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return dsTarget;
        }
        public DataSet GetGAAUF(DataSet dsTarget, DataRow dwABPOS)
        {
            string TableName = "GAAUF";
            try
            {

                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT DISTINCT GAART, GAVAR,GAFARBE,GSCBEZ,GAKG1,GAKG3,GAKG5,GAKG6, "
               + " GAKG5-GAKG6 AS GAKG7,TRIM(GSAGARNNR)||TRIM(GSGARNBEZ)||TRIM(GSHANDLNR) AS DES "
               + " FROM INTEX.GAAUF,INTEX.GSDAT ,INTEX.GSCOLOR WHERE GAMANDANT = GSMANDANT AND GAART = GSART "
               + " AND GAVAR = GSVAR AND GAMANDANT = GSCMANDANT(+) AND GAART = GSCART(+) AND GAVAR = GSCVAR(+) "
               + " AND GAFARBE = GSCFARBE(+)  AND GASA in ('732','733') AND GADISPOKZ = 'B' "
               + " AND GAAUFKRS = :GAAUFKRS AND GAAUFLFD=:GAAUFLFD AND GAAUFPOS=:GAAUFPOS";
                orlReadCommand.Parameters.Add("GAAUFKRS", OracleType.NVarChar).Value = dwABPOS["ABPAUFKRS"].ToString();
                orlReadCommand.Parameters.Add("GAAUFLFD", OracleType.NVarChar).Value = dwABPOS["ABPAUFLFD"].ToString();
                orlReadCommand.Parameters.Add("GAAUFPOS", OracleType.NVarChar).Value = dwABPOS["ABPAUFPOS"].ToString();
                Double QTY = System.Convert.ToDouble(dwABPOS["QTY"].ToString());
                Double QUANTITY = System.Convert.ToDouble(dwABPOS["QUANTITY"].ToString());
                dsResult = Connect2Proxy(orlReadCommand);
                if (dsResult.Tables.Count > 0)
                {
                    dsResult.Tables[0].TableName = TableName;
                    
                    Queue Q100 = new Queue();
                    Q100.Enqueue("GAKG1");
                    Q100.Enqueue("GAKG3");
                    Q100.Enqueue("GAKG5");
                    Q100.Enqueue("GAKG6");
                    Q100.Enqueue("GAKG7");
                    DivideBy100(dsResult.Tables[TableName], Q100);
                    dsResult.AcceptChanges();

                    byte[] b;
                    string value;
                    double GAKG1;
                    foreach (DataRow dw in dsResult.Tables[TableName].Rows)
                    {
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw["DES"].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dw["DES"] = value;
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw["GSCBEZ"].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dw["GSCBEZ"] = value;
                        GAKG1 =System.Convert.ToDouble(dw["GAKG1"].ToString());
                        GAKG1 = QUANTITY / QTY * GAKG1;
                        dw["GAKG1"] = System.Math.Round(GAKG1,2);
                         
                         
                        
                    }
                    Tracer.Speak("共有" + dsResult.Tables[TableName].Rows.Count + "种纬纱");
                }
                foreach (DataTable dtTemp in dsResult.Tables)
                {
                    if (dsTarget.Tables.Contains(TableName))
                    {
                        dsTarget.Tables[TableName].Clear();
                    }
                    dsTarget = ImportDataTable(dsTarget, dtTemp);
                }
                dsTarget.AcceptChanges();
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return dsTarget;
        }
        public DataSet GetSAMPLEORDER(DataSet dsTarget,DataRow dwABPOS)
        {
            string TableName = "SAMPLEORDER";
            try
            {
                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT Distinct ''AS LSNAME1,C.ABPAUFKRS ,C.ABPAUFLFD,C.ABPAUFPOS, "
                    + "  C.ABPAUFKRS ||'-'||TO_NUMBER(C.ABPAUFLFD)||'-'||TO_NUMBER(C.ABPAUFPOS) AS WEAVINGORDER, "
                    + "  C.ABPSTARTDAT, TRIM(C.ABPART)||'-'||TRIM(C.ABPFARBE)||'-'||TRIM(C.ABPVAR) AS ARTICLE,  "
                    + "  C.ABPSOLLMENGE1/100 AS GREIGEQTY,TRUNC(C.ABPSOLLMENGE1/100/E.WAKEAFAKTR*1000) AS QTY, "
                    + "  B.ABASANZSTK*B.ABASSTKLG/1000 as WARPQTY, "
                    + "  TRIM(F.GAART)||'/'||TRIM(F.GAVAR)||'/'||TRIM(F.GAFARBE) AS YARN, TRIM(G.GSGARNBEZ)||TRIM(GSHANDLNR) AS DES, "
                    + "  A.ABPAUFKRS||'-'||TO_NUMBER(A.ABPAUFLFD)||'-'||TO_NUMBER(A.ABPAUFPOS) AS WARPINGORDER, "
                    + "  H.GSCBEZ AS COLOR,F.GAKG3/100 AS ALLOCATION,'' AS SPPART, "
                    + "  ROUND((B.ABASANZSTK*B.ABASSTKLG/1000)/TRUNC(C.ABPSOLLMENGE1/100/E.WAKEAFAKTR*1000)*F.GAKG1/100,2) AS REQUIREMENT, "
                    + "  (F.GAKG5-F.GAKG6)/100 AS REMAIN "
                    + " FROM ABPOS A,ABAUFM B,ABPOS C,WASTKE E,GAAUF F,GSDAT G,GSCOLOR H "
                    + " WHERE A.ABPMANDANT =B.ABAMANDANT AND A.ABPAUFKRS = B.ABAAUFKRS "
                    + " AND A.ABPAUFLFD = B.ABAAUFLFD AND A.ABPAUFPOS = B.ABAAUFPOS "
                    + " AND B.ABAMANDANT = C.ABPMANDANT AND B.ABAVKAUFKRS = C.ABPAUFKRS "
                    + " AND B.ABAVKAUFLFD = C.ABPAUFLFD AND B.ABAVKAUFPOS = C.ABPAUFPOS "
                    + " AND C.ABPMANDANT = E.WAKMANDANT AND C.ABPART = E.WAKART "
                    + " AND TRIM(C.ABPVAR) = TRIM(E.WAKVAR) AND C.ABPFARBE = E.WAKWCOL "
                    + " AND C.ABPMANDANT = F.GAMANDANT AND C.ABPAUFKRS = F.GAAUFKRS "
                    + " AND C.ABPAUFLFD = F.GAAUFLFD AND C.ABPAUFPOS = F.GAAUFPOS AND F.GAMANDANT = G.GSMANDANT "
                    + " AND F.GAART = G.GSART  AND F.GAVAR = G.GSVAR AND F.GAMANDANT = H.GSCMANDANT(+) "
                    + " AND F.GAART = H.GSCART(+) AND F.GAVAR = H.GSCVAR(+)  AND F.GAFARBE = H.GSCFARBE(+) "
                    + " AND  F.GASA IN ('732','733') AND B.ABAAPOS > '0001'"
                    + " AND A.ABPAUFKRS = :ABPAUFKRS AND A.ABPAUFLFD=:ABPAUFLFD AND A.ABPAUFPOS = :ABPAUFPOS "
                    + " ORDER BY 1,2,3,4";
                orlReadCommand.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = dwABPOS["KRS"].ToString();
                orlReadCommand.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = dwABPOS["LFD"].ToString();
                orlReadCommand.Parameters.Add("ABPAUFPOS", OracleType.NVarChar).Value = dwABPOS["POS"].ToString();
                dsResult = Connect2Proxy(orlReadCommand);
                if (dsResult.Tables.Count > 0)
                {
                    dsResult.Tables[0].TableName = TableName;

                    byte[] b;
                    string value;
                    foreach (DataRow dw in dsResult.Tables[TableName].Rows)
                    {
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw["DES"].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dw["DES"] = value;
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw["COLOR"].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dw["COLOR"] = value;
                    }
                }
                foreach (DataTable dtTemp in dsResult.Tables)
                {
                    DataSet setUI = new DataSet();
                    setUI = ImportDataTable(setUI, dtTemp);
                    DataTable tableABPOS = setUI.Tables["SAMPLEORDER"];
                    foreach (DataRow dwTmp in tableABPOS.Rows)
                    {
                        //setUI = GetABAUFM(setUI, dwTmp);
                        setUI = GetABFOLGE(setUI, dwTmp);
                        setUI = GetZUTEI(setUI, dwTmp);
                    }
                    if (dsTarget.Tables.Contains(TableName))
                    {
                        dsTarget.Tables[TableName].Clear();
                    }
                    dsTarget = ImportDataTable(dsTarget, setUI.Tables["SAMPLEORDER"]);
                }
                dsTarget.AcceptChanges();
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return dsTarget;
        }
        public DataSet GetTECHSAMPLE(DataSet dsTarget, DataRow dwABPOS)
        {
            string TableName = "TECHSAMPLE";
            try
            {
                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT Distinct ''AS LSNAME1,C.ABPAUFKRS ,C.ABPAUFLFD,C.ABPAUFPOS, "
                    + "  C.ABPAUFKRS ||'-'||TO_NUMBER(C.ABPAUFLFD)||'-'||TO_NUMBER(C.ABPAUFPOS) AS WEAVINGORDER, "
                    + "  C.ABPSTARTDAT, TRIM(C.ABPART)||'-'||TRIM(C.ABPFARBE)||'-'||TRIM(C.ABPVAR) AS ARTICLE,  "
                    + "  C.ABPSOLLMENGE1/100 AS GREIGEQTY,TRUNC(C.ABPSOLLMENGE1/100/E.WAKEAFAKTR*1000) AS WARPQTY, "
                    + "  '' AS YARN,'' AS DES, "
                    + "  A.ABPAUFKRS||'-'||TO_NUMBER(A.ABPAUFLFD)||'-'||TO_NUMBER(A.ABPAUFPOS) AS WARPINGORDER, "
                    + "  '' AS COLOR,'' AS REQUIREMENT,'' AS ALLOCATION, "
                    + "  '' AS REMAIN "
                    + " FROM ABPOS A,ABAUFM B,ABPOS C,WASTKE E "
                    + " WHERE A.ABPMANDANT =B.ABAMANDANT AND A.ABPAUFKRS = B.ABAAUFKRS "
                    + " AND A.ABPAUFLFD = B.ABAAUFLFD AND A.ABPAUFPOS = B.ABAAUFPOS "
                    + " AND B.ABAMANDANT = C.ABPMANDANT AND B.ABAVKAUFKRS = C.ABPAUFKRS "
                    + " AND B.ABAVKAUFLFD = C.ABPAUFLFD AND B.ABAVKAUFPOS = C.ABPAUFPOS "
                    + " AND C.ABPMANDANT = E.WAKMANDANT AND C.ABPART = E.WAKART "
                    + " AND TRIM(C.ABPVAR) = TRIM(E.WAKVAR) AND C.ABPFARBE = E.WAKWCOL "                   
                    + " AND A.ABPAUFKRS = :ABPAUFKRS AND A.ABPAUFLFD=:ABPAUFLFD AND A.ABPAUFPOS = :ABPAUFPOS "
                    + " ORDER BY 1,2,3,4";
                orlReadCommand.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = dwABPOS["KRS"].ToString();
                orlReadCommand.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = dwABPOS["LFD"].ToString();
                orlReadCommand.Parameters.Add("ABPAUFPOS", OracleType.NVarChar).Value = dwABPOS["POS"].ToString();
                dsResult = Connect2Proxy(orlReadCommand);
                if (dsResult.Tables.Count > 0)
                {
                    dsResult.Tables[0].TableName = TableName;

                    byte[] b;
                    string value;
                    foreach (DataRow dw in dsResult.Tables[TableName].Rows)
                    {                        
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw["DES"].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dw["DES"] = value;
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw["COLOR"].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dw["COLOR"] = value;
                    }
                }
                foreach (DataTable dtTemp in dsResult.Tables)
                {
                    DataSet setUI = new DataSet();
                    setUI = ImportDataTable(setUI, dtTemp);
                    DataTable tableABPOS = setUI.Tables["TECHSAMPLE"];
                    foreach (DataRow dwTmp in tableABPOS.Rows)
                    {
                        //setUI = GetABAUFM(setUI, dwTmp);
                        setUI = GetABFOLGE(setUI, dwTmp);
                    }
                    if (dsTarget.Tables.Contains(TableName))
                    {
                        dsTarget.Tables[TableName].Clear();
                    }
                    dsTarget = ImportDataTable(dsTarget, setUI.Tables["TECHSAMPLE"]);
                }
                dsTarget.AcceptChanges();
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return dsTarget;
        }
        public DataSet GetABPOS(DataSet dsTarget, DataRow dwABPOS)
        {
            string TableName = "ABPOS";
            try
            {
                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT Distinct ''AS LSNAME1,ABPAUFKRS ,ABPAUFLFD,ABPAUFPOS, "
                    + " ABPAUFKRS ||'-'||TO_NUMBER(ABPAUFLFD)||'-'||TO_NUMBER(ABPAUFPOS) AS WEAVINGORDER, ABPSTARTDAT, "
                    + " TRIM(ABPART)||'-'||TRIM(ABPFARBE)||'-'||TRIM(ABPVAR) AS ARTICLE, "
                    + " ABPSOLLMENGE1/100 AS GREIGEQTY,TRUNC(ABPSOLLMENGE1/100/WAKEAFAKTR*1000)AS QTY,0 AS WARPQTY, "
                    + " TRIM(GAART)||'/'||TRIM(GAVAR)||'/'||TRIM(GAFARBE) AS YARN, "
                    + " TRIM(GSGARNBEZ)||TRIM(GSHANDLNR) AS DES,'' WARPINGORDER,'' AS SPPART, "
                    + " GSCBEZ AS COLOR,GAKG1/100 AS REQUIREMENT,GAKG3/100 AS ALLOCATION,(GAKG5-GAKG6)/100 AS REMAIN "
                    + " FROM INTEX.ABPOS,INTEX.WASTKE,INTEX.LIEFDAT,INTEX.GAAUF,INTEX.GSDAT,INTEX.GSCOLOR  "
                    + " WHERE  ABPMANDANT = WAKMANDANT AND ABPART = WAKART "
                    + " AND TRIM(ABPVAR) = TRIM(WAKVAR) AND ABPFARBE = WAKWCOL  "
                    + " AND ABPMANDANT = GAMANDANT AND ABPAUFKRS = GAAUFKRS "
                    + " AND ABPAUFLFD = GAAUFLFD AND ABPAUFPOS = GAAUFPOS AND GAMANDANT = GSMANDANT "
                    + " AND GAART = GSART  AND GAVAR = GSVAR AND GAMANDANT = GSCMANDANT(+)  "
                    + " AND GAART = GSCART(+) AND GAVAR = GSCVAR(+)  AND GAFARBE = GSCFARBE(+) "
                    + " AND  GASA in ('732','733') AND GADISPOKZ = 'B'"
                    + " AND ABPAUFKRS = :ABPAUFKRS AND ABPAUFLFD=:ABPAUFLFD AND ABPAUFPOS = :ABPAUFPOS ";
                orlReadCommand.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = dwABPOS["ABPAUFKRS"].ToString();
                orlReadCommand.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = dwABPOS["ABPAUFLFD"].ToString();
                orlReadCommand.Parameters.Add("ABPAUFPOS", OracleType.NVarChar).Value = dwABPOS["ABPAUFPOS"].ToString();
                dsResult = Connect2Proxy(orlReadCommand);
                if (dsResult.Tables.Count > 0)
                {
                    dsResult.Tables[0].TableName = TableName;

                    byte[] b;
                    string value;
                    foreach (DataRow dw in dsResult.Tables[TableName].Rows)
                    {
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw["DES"].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dw["DES"] = value;
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw["COLOR"].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dw["COLOR"] = value;
                    }
                }
                foreach (DataTable dtTemp in dsResult.Tables)
                {
                    DataSet setUI = new DataSet();
                    setUI = ImportDataTable(setUI, dtTemp);
                    DataTable tableABPOS = setUI.Tables["ABPOS"];
                    foreach (DataRow dwTmp in tableABPOS.Rows)
                    {
                        setUI = GetABAUFM(setUI, dwTmp);
                        setUI = GetABFOLGE(setUI, dwTmp);
                        setUI = GetZUTEI(setUI, dwTmp);
                    }
                    foreach(DataRow rowABPOS in setUI.Tables["ABPOS"].Rows )
                    {
                        double WARPQTY = System.Convert.ToDouble(rowABPOS["WARPQTY"].ToString());
                        double QTY = System.Convert.ToDouble(rowABPOS["QTY"].ToString());
                        double REQUIREMENT = System.Convert.ToDouble(rowABPOS["REQUIREMENT"].ToString());

                        REQUIREMENT = WARPQTY / QTY * REQUIREMENT;
                        rowABPOS["REQUIREMENT"] = System.Math.Round(REQUIREMENT, 2);
                    }
                    if (dsTarget.Tables.Contains(TableName))
                    {
                        dsTarget.Tables[TableName].Clear();
                    }
                    dsTarget = ImportDataTable(dsTarget, setUI.Tables["ABPOS"]);
                }
                dsTarget.AcceptChanges();
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return dsTarget;
        }
        public DataSet GetABAUFM(DataSet dsTarget, DataRow dwABPOS)
        {

            string TableName = "ABAUFM";
            try
            {
                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT distinct ABAAUFKRS||'-'||TO_NUMBER(ABAAUFLFD)||'-'||TO_NUMBER(ABAAUFPOS) AS WARPINGORDER, "
                    + " ABASANZSTK*ABASSTKLG/1000 as WARPQTY "
                    + " FROM ABAUFM,ABPOS  WHERE ABAAUFKRS = ABPAUFKRS AND ABAAUFLFD = ABPAUFLFD  "
                    + " AND ABAAUFPOS = ABPAUFPOS AND ABAAPOS >'0001' AND ABPAUFART = 'VW' "
                    + " AND  ABAVKAUFKRS = :ABAVKAUFKRS AND ABAVKAUFLFD=:ABAVKAUFLFD AND ABAVKAUFPOS=:ABAVKAUFPOS";
                orlReadCommand.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwABPOS["ABPAUFKRS"].ToString();
                orlReadCommand.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwABPOS["ABPAUFLFD"].ToString();
                orlReadCommand.Parameters.Add("ABAVKAUFPOS", OracleType.NVarChar).Value = dwABPOS["ABPAUFPOS"].ToString();
                dsResult = Connect2Proxy(orlReadCommand);
                if (dsResult.Tables.Count > 0)
                {
                    dsResult.Tables[0].TableName = "ABAUFM";
                    string orderno = "";
                    double WARPQTY = 0;
                    foreach (DataRow dwTemp in dsResult.Tables["ABAUFM"].Rows)
                    {
                        orderno += dwTemp["WARPINGORDER"].ToString() + ";";
                        WARPQTY += System.Convert.ToDouble(dwTemp["WARPQTY"].ToString());
                    }
                    dwABPOS["WARPINGORDER"] = orderno;
                    dwABPOS["WARPQTY"] = WARPQTY;
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return dsTarget;

        }
        public DataSet GetZUTEI(DataSet dsTarget, DataRow dwABPOS)
        {

            try
            {
                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT DISTINCT TRIM(ZUSPPART) AS ZUSPPART "
                    + " FROM ZUTEI  WHERE ZUAUFKRS||'-'||TO_NUMBER(ZUAUFLFD)||'-'||TO_NUMBER(ZUAUFPOS) = :ORDERNO "
                    + " AND TRIM(ZUART)||'/'||TRIM(ZUVAR)||'/'||TRIM(ZUFARBE) = :YARN ";
                orlReadCommand.Parameters.Add("ORDERNO", OracleType.NVarChar).Value = dwABPOS["WEAVINGORDER"].ToString();
                orlReadCommand.Parameters.Add("YARN", OracleType.NVarChar).Value = dwABPOS["YARN"].ToString();
                dsResult = Connect2Proxy(orlReadCommand);
                if (dsResult.Tables.Count > 0)
                {
                    dsResult.Tables[0].TableName = "ZUTEI";
                    string SPPART = "";
                    foreach (DataRow dwTemp in dsResult.Tables["ZUTEI"].Rows)
                    {
                        SPPART += dwTemp["ZUSPPART"].ToString() + ";";
                    }
                    dwABPOS["SPPART"] = SPPART;
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return dsTarget;

        }
        public DataSet BuildAB55DIData(DataSet dsTarget, DataRow dwABPOS)
        {
            try
            {
                dsTarget = GetABPOS(dsTarget, dwABPOS);

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return dsTarget;
        }
        public DataSet BuildSAMPLEORDERData(DataSet dsTarget, DataRow dwABPOS)
        {
            try
            {
                dsTarget = GetSAMPLEORDER(dsTarget,dwABPOS);

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return dsTarget;
        }
        public DataSet BuildTECHSAMPLEData(DataSet dsTarget, DataRow dwABPOS)
        {
            try
            {
                dsTarget = GetTECHSAMPLE(dsTarget, dwABPOS);

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return dsTarget;
        }

    }
}